﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MBS.UserControls.CinemaUserControl
{
    public partial class CinemaList : System.Web.UI.UserControl
    {
        #region transfer

        MBSBLC.BLC cinemablc=new MBSBLC.BLC();
        Dictionary<int, string> dct;

        public delegate void CinemaListHandler(int SelectedValue);

        public event CinemaListHandler CimeListChanged;


        private int cinemaID;

        public int CinemaID
        {
            get { return cinemaID; }
            set { cinemaID = value; }
        }


        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                cinemablc = new MBSBLC.BLC();
            }
        }

        public void LoadDropDownBox()
        {
        
                dct = new Dictionary<int, string>();
                dct = cinemablc.GetAllCinemas();
                DropDownList1.DataSource = dct;
                DropDownList1.DataTextField = "Value";
                DropDownList1.DataValueField = "Key";
                DropDownList1.DataBind();
        
        }

        public int GetSelectedValue()
        {
            CinemaID = Convert.ToInt32(DropDownList1.SelectedValue.Equals("")?"0":DropDownList1.SelectedValue);
            return CinemaID;
            
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            CimeListChanged(GetSelectedValue());
        }

        #endregion
    }
}